package com.mai4j.maiadmin.support;

import com.mai4j.maiadmin.support.i18n.I18n;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * 微信公众号请关注: 开源螺丝钉
 * <br>
 * 码云请关注: <a href="https://gitee.com/xiyoufang">https://gitee.com/xiyoufang</a>
 * <br>
 * 哔哩哔哩请关注: <a href="https://space.bilibili.com/438927834">https://space.bilibili.com/438927834</a>
 *
 * @author xiyoufang
 */
@Component
public class I18nProvider implements ApplicationContextAware {

    private static I18n i18n;

    public static String get(String key) {
        return i18n.get(key);
    }

    public static String getByTag(String key, String tag) {
        return i18n.getByTag(key, tag);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        I18nProvider.i18n = applicationContext.getBean(I18n.class);
    }
}
